home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 7.6 KB | 212 lines | [TEXT/CWIE] |
- //----------------------------------------------------------------------------------------
- // UODPartViewCommands.cp
- // Copyright © 1994-96 by Apple Computer, Inc. All rights reserved.
- //----------------------------------------------------------------------------------------
-
- #if qContainer
-
- #ifndef __UODPARTVIEWCOMMANDS__
- #include "UODPartViewCommands.h"
- #endif
-
- #ifndef __UODPARTVIEW__
- #include "UODPartView.h"
- #endif
-
-
- //========================================================================================
- // CLASS TCopyODPartCommand
- //========================================================================================
- #undef Inherited
- #define Inherited TCommand
-
- #pragma segment MASelCommand
- MA_DEFINE_CLASS_M1(TCopyODPartCommand, Inherited);
-
- //----------------------------------------------------------------------------------------
- // TCopyODPartCommand::TCopyODPartCommand
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- TCopyODPartCommand::TCopyODPartCommand()
- {
-
- } // TCopyODPartCommand::TCopyODPartCommand
-
- //----------------------------------------------------------------------------------------
- // TCopyODPartCommand::ICopyODPartCommand
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- void TCopyODPartCommand::ICopyODPartCommand(CommandNumber itsCommandNumber,
- TDocument* itsDocument,
- TODPartView* thePartView)
- {
- fDocument = itsDocument;
- fODPartView = thePartView;
- this->ICommand(itsCommandNumber, NULL, kCantUndo, kDoesNotCauseChange, NULL);
- } // TCopyODPartCommand::ICopyODPartCommand
-
- //----------------------------------------------------------------------------------------
- // TCopyODPartCommand::~TCopyODPartCommand
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
-
- TCopyODPartCommand::~TCopyODPartCommand()
- {
- } // TCopyODPartCommand::~TCopyODPartCommand
-
- //----------------------------------------------------------------------------------------
- // TCopyODPartCommand::DoIt
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
-
- void TCopyODPartCommand::DoIt()
- {
- CADocumentRef theClipboardDocument = CAGetClipboardDocument();
- CADocumentRef sourceDocument = fDocument->GetContainer();
- CAFrameRef sourceFrameRef = fODPartView->GetFrameRef();
- CACloneKey cloneKey = CABeginClone(sourceDocument, theClipboardDocument, kCACloneCopy);
- CAFrameRef clipFrameRef = CACloneFrameRef(sourceFrameRef,sourceDocument,
- theClipboardDocument,TRUE,cloneKey);
- CAEndClone(sourceDocument,theClipboardDocument,cloneKey);
- } // TCopyODPartCommand::DoIt
-
-
-
- //========================================================================================
- // CLASS TCutODPartCommand
- //========================================================================================
- #undef Inherited
- #define Inherited TCommand
-
- #pragma segment MASelCommand
- MA_DEFINE_CLASS_M1(TCutODPartCommand, Inherited);
-
- //----------------------------------------------------------------------------------------
- // TCutODPartCommand::TCutODPartCommand
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- TCutODPartCommand::TCutODPartCommand()
- {
-
- } // TCutODPartCommand::TCutODPartCommand
-
- //----------------------------------------------------------------------------------------
- // TCutODPartCommand::ICutODPartCommand
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- void TCutODPartCommand::ICutODPartCommand(CommandNumber itsCommandNumber,
- TDocument* itsDocument,
- TODPartView* thePartView)
- {
- fDocument = itsDocument;
- fODPartView = thePartView;
- this->ICommand(itsCommandNumber, NULL, kCantUndo, kCausesChange, NULL);
- } // TCutODPartCommand::ICutODPartCommand
-
- //----------------------------------------------------------------------------------------
- // TCutODPartCommand::~TCutODPartCommand
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- TCutODPartCommand::~TCutODPartCommand()
- {
- } // TCutODPartCommand::~TCutODPartCommand
-
- //----------------------------------------------------------------------------------------
- // TCutODPartCommand::DoIt
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- void TCutODPartCommand::DoIt()
- {
- CADocumentRef theClipDocument = CAGetClipboardDocument();
- CADocumentRef sDocument = fDocument->GetContainer();
- CAFrameRef sFrameRef = fODPartView->GetFrameRef();
- CACloneKey cKey = CABeginClone(sDocument, theClipDocument, kCACloneCut);
- CAFrameRef cRef = CACloneFrameRef(sFrameRef,sDocument,
- theClipDocument,TRUE,cKey);
- CAEndClone(sDocument,theClipDocument,cKey);
- fODPartView->RemovePart(); //not condusive to an undo! (Save it off, remove it in committ)
- } // TCutODPartCommand::DoIt
-
-
- //========================================================================================
- // CLASS TPasteODPartCommand
- //========================================================================================
- #undef Inherited
- #define Inherited TCommand
-
- #pragma segment MASelCommand
- MA_DEFINE_CLASS_M1(TPasteODPartCommand, Inherited);
-
- //----------------------------------------------------------------------------------------
- // TPasteODPartCommand::TPasteODPartCommand
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- TPasteODPartCommand::TPasteODPartCommand()
- {
-
- } // TPasteODPartCommand::TPasteODPartCommand
-
- //----------------------------------------------------------------------------------------
- // TPasteODPartCommand::IPasteODPartCommand
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- void TPasteODPartCommand::IPasteODPartCommand(CommandNumber itsCommandNumber,
- TDocument* itsDocument,
- TODPartView* thePartView)
- {
- fDocument = itsDocument;
- fODPartView = thePartView;
- this->ICommand(itsCommandNumber, NULL, kCantUndo, kCausesChange, NULL);
- } // TPasteODPartCommand::IPasteODPartCommand
-
- //----------------------------------------------------------------------------------------
- // TPasteODPartCommand::~TPasteODPartCommand
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- TPasteODPartCommand::~TPasteODPartCommand()
- {
- } // TPasteODPartCommand::~TPasteODPartCommand
-
- //----------------------------------------------------------------------------------------
- // TPasteODPartCommand::DoIt
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- void TPasteODPartCommand::DoIt()
- {
- if(fODPartView->ContainsClipType(kCAScrapTypeODBentoContainer))
- {
- CADocumentRef theClipboardDocument;
- long scrapLength;
- long scrapOffset;
- Handle scrapHandle;
-
- //If we have a part, get rid of it
- if(fODPartView->HasPart())
- fODPartView->RemovePart();
-
- // Get the container stream
- scrapHandle = NewHandle(0);
- //Lock handle? FailOSErr!
- scrapLength = GetScrap(scrapHandle, kCAScrapTypeODBentoContainer, &scrapOffset );
-
- // Open the container
- theClipboardDocument = CAOpenDocument (NULL, scrapHandle, 0, scrapLength);
- fODPartView->AquirePartFromDocument(theClipboardDocument);
- CACloseDocument(theClipboardDocument);
- DisposeHandle(scrapHandle);
- }
- } // TPasteODPartCommand::DoIt
-
- #endif //qContainer